package com.design.pattern.principle.dependencyInversion.improve.dependCase1;

public class DependCase1 {
    public static void main(String[] args) {
        new OpenAndClose().open(new ChangHong());
    }
}

/**
 * 通过接口传递实现依赖
 */
interface IOpenAndClose {
    void open(ITV tv);
}

interface ITV {
    void play();
}

class ChangHong implements ITV {

    @Override
    public void play() {
        System.out.println("长虹电视机。打开");
    }
}

class OpenAndClose implements IOpenAndClose {
    @Override
    public void open(ITV tv) {
        tv.play();
    }
}
